//
//  ZJSubjectClassViewController.m
//  ZhongWangYuanApp
//
//  Created by ZJ on 2019/1/29.
//  Copyright © 2019 apple. All rights reserved.
//

#import "ZJSubjectClassViewController.h"
#import "ZJSubjctClassGTDeatilViewController.h"
@interface ZJSubjectClassViewController ()
@property (strong, nonatomic) GTPageController  *gtPageVc;
@end

@implementation ZJSubjectClassViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    if (!self.isNOTaBVC) {
         self.leftButton.hidden = YES;
    }
    [self layoutUI];
}

- (void)layoutUI{

    self.gtPageVc = [self getDefaultController];
    self.gtPageVc.Notscroll = NO;
    self.gtPageVc.view.frame = CGRectMake(0, LP_NavViewHeight, self.view.width, [UIScreen zj_screenHeight] - LP_NavViewHeight);
    [self.view addSubview:self.gtPageVc.view];
    [self addChildViewController:self.gtPageVc];
    
    self.gtPageVc.view.sd_layout
    .leftSpaceToView(self.view , 0)
    .rightSpaceToView(self.view , 0)
    .topSpaceToView(self.navigView , 0);
    if (!self.isNOTaBVC) {
        self.gtPageVc.view.sd_layout.bottomSpaceToView(self.view ,LP_TabBarHeight);
    }else{
         self.gtPageVc.view.sd_layout.bottomSpaceToView(self.view ,0);
    }
    
    
}


#pragma mark - 私有方法
- (GTPageController *)getDefaultController{
    
    ZJSubjctClassGTDeatilViewController *learnerVC = [ZJSubjctClassGTDeatilViewController new];
    NSArray *titles = @[@"我的专题班" , @"可报名专题班"];
    
    NSArray *viewVcs = @[[learnerVC class],[learnerVC class]];
    GTPageControllModel *model1 = [GTPageControllModel new];
    GTPageControllModel *model2 = [GTPageControllModel new];
    model1.classApplyType = @"1";
    model2.classApplyType = @"0";
    NSArray * modelArray = @[model1,model2];
    
    __block NSMutableArray *titlesWidth = [NSMutableArray array];
    [titles enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        CGFloat width = [NSString sizeOfString:obj font:16 * [UIScreen zj_textFontScale]  width:self.view.width].width + 12 * [UIScreen zj_screenWScale];
        [titlesWidth addObject:@(width * 1.6)];
    }];
    
    GTPageController *pageVC = [[GTPageController alloc] initWithViewControllerClasses:viewVcs andTheirTitles:titles];
    pageVC.pageAnimatable = YES;
    pageVC.modelArray = modelArray;
    pageVC.itemsWidths = titlesWidth;
    pageVC.postNotification = YES;
    pageVC.menuBGColor = [UIColor clearColor];
    pageVC.menuViewStyle = GTMenuViewStyleLine;
    pageVC.progressColor = [UIColor themeColor];
    pageVC.titleColorSelected = [UIColor themeColor];
    pageVC.titleColorNormal = [UIColor textGrayColor];
    pageVC.titleSizeNormal = 16 * [UIScreen zj_textFontScale];
    pageVC.titleSizeSelected = 17 * [UIScreen zj_textFontScale];
    pageVC.menuHeight = 50 * [UIScreen zj_screenHScale];
    return pageVC;
}

@end
